package com.peaksport.framework.metadata.view;

import com.peaksport.framework.metadata.filter.FilterInfo;
import com.peaksport.framework.metadata.filter.FilterItemInfo;
import com.peaksport.framework.metadata.parse.QueryParse;
import com.peaksport.framework.metadata.query.PageParams;
import com.peaksport.framework.metadata.query.QueryInfo;
import com.peaksport.framework.metadata.sorter.SorterItemCollection;
import com.peaksport.framework.util.PKPublicUtils;

/**
 * TODO 待修改实现
 * Created by guoguo on 2017-02-04.
 */
public class QueryViewInfo {

    private static final String SPACE = PKPublicUtils.SPACE;
    private static final String COMMA = PKPublicUtils.COMMA;
    private static final String CR = PKPublicUtils.CR;


    /** query 对象 */
    private QueryInfo queryInfo;
    /** 管理单元 过滤条件*/
    private FilterItemInfo defaultCUFilterItemInfo;
    /** 主业务组织 过滤条件*/
    private FilterItemInfo defaultMainOrgFilterItemInfo;
    /** 过滤条件*/
    private FilterInfo filterInfo;
    /** 分页信息 */
    private PageParams pageParams;
    /** 排序字段*/
    private SorterItemCollection sortFieldCol;
    /** 是否删除列F前缀 */
    private boolean isRemoveColumnPrefixF = true;

    public QueryViewInfo(QueryInfo queryInfo) {
        this.queryInfo = queryInfo;
    }

    public void setQueryInfo(QueryInfo queryInfo) {
        this.queryInfo = queryInfo;
    }

    public QueryInfo getQueryInfo() {
        return queryInfo;
    }

    public void setRemoveColumnPrefixF(boolean removeColumnPrefixF) {
        isRemoveColumnPrefixF = removeColumnPrefixF;
    }

    public PageParams getPageParams() {
        return pageParams;
    }

    public void setPageParams(PageParams pageParams) {
        this.pageParams = pageParams;
    }

    public void setSortFieldCol(SorterItemCollection sortFieldCol) {
        this.sortFieldCol = sortFieldCol;
    }

    public SorterItemCollection getSortFieldCol() {
        return sortFieldCol;
    }

    public void setFilterInfo(FilterInfo filterInfo) {
        this.filterInfo = filterInfo;
    }

    public FilterInfo getFilterInfo() {
        return filterInfo;
    }

    public FilterItemInfo getDefaultCUFilterItemInfo() {
        return defaultCUFilterItemInfo;
    }

    public FilterItemInfo getDefaultMainOrgFilterItemInfo() {
        return defaultMainOrgFilterItemInfo;
    }

    public String toSQL() throws Exception {
        QueryParse parse = new QueryParse(this);
        return parse.toSQL();
    }

    public String toRowCountSQL() throws Exception{
        QueryParse parse = new QueryParse(this);
        return parse.toRowCountSQL();
    }
}
